package com.coocaa.ops.api.base.third.dmp;

import com.coocaa.ops.api.base.third.dmp.cache.DmpCrowdCache;
import com.coocaa.ops.api.base.third.dmp.handler.DmpHandler;
import com.coocaa.ops.api.base.third.dmp.model.DmpCrowdModel;
import com.coocaa.ops.api.common.model.HeaderModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author tangminghong
 * @date 2020-09-04
 */
@Service
public class DmpServiceImpl implements IDmpService {

    @Autowired
    private DmpCrowdCache dmpCrowdCache;

    @Override
    public Set<Integer> getMatchedCrowdIdsFromDmp(Set<Integer> policyIds, HeaderModel header) {
        List<DmpCrowdModel> crowdModelList = dmpCrowdCache.getDmpCrowdCaches(header, policyIds);
        return new HashSet<>(DmpHandler.parseCrowdIds(crowdModelList));
    }

}
